home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-21 / api92.zip / BASICAPI.ZIP / REC.BAS next >
BASIC Source File  |  1991-12-24  |  2KB  |  91 lines

  1. DECLARE SUB ProgramBody ()
  2. '***************************************************************************
  3. '*
  4. '*  Name:               Receive
  5. '*
  6. '*  Function:           Receive Mailbox
  7. '*
  8. '***************************************************************************
  9.  
  10. ' $INCLUDE: 'dvapi.bi'
  11.  
  12. ' minimum API version required and actual API version
  13. CONST required = &H201
  14.  
  15. DIM version AS INTEGER
  16. ' Object handles
  17. DIM SHARED win&, kbd&, malhan&
  18.  
  19. ' Variables used when reading the menu keyboard
  20. DIM SHARED kbuf$, selfield%
  21.  
  22.  
  23. '***************************************************************************
  24. ' Main Module - check for DESQview present and enable required extensions
  25. '***************************************************************************
  26.  
  27. ' Initialize DESQview interface and get API version number
  28. version = ApiInit%
  29.  
  30. ' If DESQview is not running or version is too low, display a message
  31. IF version < required THEN
  32.     OPEN "CONS:" FOR OUTPUT AS 1
  33.     PRINT #1, USING "This program requires DESQview version #.##"; required \ 256 + (required MOD 256) / 100
  34.     CLOSE 1
  35. ELSE
  36. ' Tell DESQview what extensions to enable and start application
  37.     CALL ApiLevel(required)
  38.     CALL ProgramBody
  39. END IF
  40.  
  41. ' Disable DESQview interface and return from program
  42. CALL ApiExit
  43.  
  44. SUB ProgramBody
  45. '***************************************************************************
  46. ' ProgramBody - build menu and display message when item selected
  47. '***************************************************************************
  48.     Attempt! = 0
  49.     OPEN "Cons:" FOR OUTPUT AS #1
  50. '
  51. ' First, get our Mailbox Handle
  52. '
  53.     malhan& = MalMe&
  54. '
  55. ' Assign global name "Receive"
  56. '
  57.     CALL MalName(malhan&, "Receive")
  58. '
  59. ' Look for the Receive mailbox; loop until found
  60. '
  61. Find:   SendHan& = MalFind&("Send")
  62.     IF SendHan& = 0 THEN
  63.         PRINT #1, "<NODE NOT FOUND>";
  64.         GOTO Find
  65.     END IF
  66. '
  67. ' At this point, SendHan& is mailbox of receiver
  68. '
  69.  
  70. '
  71. ' Get the message from send module
  72. '
  73. Talk:   Message$ = MalRead$(malhan&)
  74.     PRINT #1, "<RECEIVED SEND -" + Message$ + ">"
  75.     Attempt = Attempt + 1
  76.     msg$ = STR$(Attempt)
  77.     PRINT #1, "<SEND RECEIPT>";
  78.     errstat% = MalWrite%(SendHan&, msg$)
  79.     IF errstat > 0 THEN
  80. ' Error handling would go here
  81.     END IF
  82.     GOTO Talk
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. END SUB
  90.  
  91.